﻿Public Class opEntradas


#Region " Variables de trabajo "
    Dim Caja As String = ""
    Dim Parametros As String = ""
    Dim lConsulta As New ClsConsultas
    Dim ObjRet As CRetorno
#End Region


#Region " Eventos Principales"
    Private Sub opEntradas_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Select Case e.KeyCode
            Case Keys.F2
                'Me.Catalogo()
            Case Keys.Escape
                Cerrar()
            Case Keys.F4
                Limpiar.PerformClick()
            Case Keys.F9
                Grabar.PerformClick()
        End Select
    End Sub

    Private Sub opEntradas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Pie de Pagina Mensaje
        MensajePiePagina.Text = "Esc=Salir F4=Limpiar Pantalla F9=Grabar"
        'Deshabilitar

    End Sub

#End Region

#Region " Grabar "
    Private Sub Grabar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Grabar.Click

        'Variable de trabajo
        Dim Result As DialogResult
        Result = MessageBox.Show("¿Deseas Realizar la entrada a caja?", "PVFacturacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
        If Result = Windows.Forms.DialogResult.Yes Then

            Caja = "Grabar160" : Parametros = "V1=" & Me.TxtImporte.Text & "|V2=" & Me.txtDescripcion.Text & _
                                              "|V3=" & Me.DateTimePicker1.Value.ToString("MM/dd/yyyy HH:mm:ss") & "|V4=1|"
            If lConsulta Is Nothing Then lConsulta = New ClsConsultas
            ObjRet = lConsulta.LlamarCaja(Caja, "1", Parametros)
            MessageBox.Show(lConsulta.ObtenerValor("2M", ObjRet.sResultado, "|", False))
            If ObjRet.bOk Then
                limpiarPantalla()
            End If
            
        End If
    End Sub
#End Region

#Region " Limpiar "
    Private Sub Limpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Limpiar.Click
        limpiarPantalla()
    End Sub
#End Region

#Region " Rutinas "
    Sub limpiarPantalla()
        Me.txtDescripcion.Text = ""
        Me.TxtImporte.Text = ""
        Me.DateTimePicker1.Value = DateTime.Now
    End Sub

    Sub Cerrar()
        Dim Result As DialogResult
        Result = MessageBox.Show("¿Deseas salir de esta pantalla?", "Evans", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
        If Result = Windows.Forms.DialogResult.Yes Then
            Me.Close()
        End If
    End Sub
#End Region
End Class